Handle C-h when buffer not showing
authorJustin Burkett <justin@burkett.cc>
Sat, 27 May 2017 19:34:54 +0000 (15:34 -0400)
committerJustin Burkett <justin@burkett.cc>
Sat, 27 May 2017 21:48:10 +0000 (17:48 -0400)
which-key-C-h-dispatch was not doing anything different if the which-key buffer
was not showing. This makes it fall back to the standard Emacs behavior.

Fixes #172

which-key.el

index 137ab41d1e23d8411068e1a1d8abbd17784d8ff3..ab3b3e1dea4d4cb213f4c6df40571856936281ca 100644 (file)
@@ -2056,34 +2056,36 @@ after first page."
 `which-key-C-h-map'. This command is always accessible (from any
 prefix) if `which-key-use-C-h-commands' is non nil."
   (interactive)
-  (let* ((prefix-keys (key-description which-key--current-prefix))
-         (full-prefix (which-key--full-prefix prefix-keys current-prefix-arg t))
-         (prompt (concat (when (string-equal prefix-keys "")
+  (if (not (which-key--popup-showing-p))
+      (which-key-show-standard-help)
+    (let* ((prefix-keys (key-description which-key--current-prefix))
+           (full-prefix (which-key--full-prefix prefix-keys current-prefix-arg t))
+           (prompt (concat (when (string-equal prefix-keys "")
+                             (propertize
+                              (concat " "
+                                      (or which-key--current-show-keymap-name
+                                          "Top-level bindings"))
+                              'face 'which-key-note-face))
+                           full-prefix
                            (propertize
-                            (concat " "
-                                    (or which-key--current-show-keymap-name
-                                        "Top-level bindings"))
-                            'face 'which-key-note-face))
-                         full-prefix
-                         (propertize
-                          (substitute-command-keys
-                           (concat
-                            " \\<which-key-C-h-map>"
-                            " \\[which-key-show-next-page-cycle]"
-                            which-key-separator "next-page,"
-                            " \\[which-key-show-previous-page-cycle]"
-                            which-key-separator "previous-page,"
-                            " \\[which-key-undo-key]"
-                            which-key-separator "undo-key,"
-                            " \\[which-key-show-standard-help]"
-                            which-key-separator "help,"
-                            " \\[which-key-abort]"
-                            which-key-separator "abort"))
-                          'face 'which-key-note-face)))
-         (key (string (read-key prompt)))
-         (cmd (lookup-key which-key-C-h-map key))
-         (which-key-inhibit t))
-    (if cmd (funcall cmd) (which-key-turn-page 0))))
+                            (substitute-command-keys
+                             (concat
+                              " \\<which-key-C-h-map>"
+                              " \\[which-key-show-next-page-cycle]"
+                              which-key-separator "next-page,"
+                              " \\[which-key-show-previous-page-cycle]"
+                              which-key-separator "previous-page,"
+                              " \\[which-key-undo-key]"
+                              which-key-separator "undo-key,"
+                              " \\[which-key-show-standard-help]"
+                              which-key-separator "help,"
+                              " \\[which-key-abort]"
+                              which-key-separator "abort"))
+                            'face 'which-key-note-face)))
+           (key (string (read-key prompt)))
+           (cmd (lookup-key which-key-C-h-map key))
+           (which-key-inhibit t))
+      (if cmd (funcall cmd) (which-key-turn-page 0)))))
 
 ;;; Update